package com.base.commonlib.utils;

import android.support.annotation.NonNull;

/**
 * Created by weikailiang on 2019/6/23.
 */

public class DeteUtil {
    /**
     * 将日转化为大写
     *
     * @param num
     * @return
     */
    @NonNull
    public static String dayToUppder(int day) {
        if (day < 20) {
            return monthToUppder(day);
        } else {
            char[] str = String.valueOf(day).toCharArray();
            if (str[1] == '0') {
                return ToUpper(Integer.parseInt(str[0] + "")) + "十";
            } else {
                return ToUpper(Integer.parseInt(str[0] + "")) + "十"
                        + ToUpper(Integer.parseInt(str[1] + ""));
            }
        }
    }
    /**
     * 将月转化为大写
     *
     * @param num
     * @return
     */
    @NonNull
    public static String monthToUppder(int month) {
        if (month < 10) {
            return ToUpper(month);
        } else if (month == 10) {
            return "十";
        } else {
            return "十" + ToUpper(month - 10);
        }
    }
    /**
     * 将数字转化为大写
     *
     * @param num
     * @return
     */
    @NonNull
    public static String ToUpper(int num) {
        // String u[] = {"零","壹","贰","叁","肆","伍","陆","柒","捌","玖"};
        String u[] = {"零", "一", "二", "三", "四", "五", "六", "七", "八", "九"};
        char[] str = String.valueOf(num).toCharArray();
        String rstr = "";
        for (int i = 0; i < str.length; i++) {
            rstr = rstr + u[Integer.parseInt(str[i] + "")];
        }
        return rstr;
    }
}
